<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<TITLE>
AsyncCallback (Google Web Toolkit Javadoc)
</TITLE>

<META NAME="keywords" CONTENT="com.google.gwt.user.client.rpc.AsyncCallback interface">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="AsyncCallback (Google Web Toolkit Javadoc)";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../../com/google/gwt/user/client/rpc/IncompatibleRemoteServiceException.html" title="class in com.google.gwt.user.client.rpc"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../../../index.html?com/google/gwt/user/client/rpc/AsyncCallback.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="AsyncCallback.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.gwt.user.client.rpc</FONT>
<BR>
Interface AsyncCallback&lt;T&gt;</H2>
<DL>
<DT><DT><B>Type Parameters:</B><DD><CODE>T</CODE> - The type of the return value that was declared in the synchronous
          version of the method. If the return type is a primitive, use the
          boxed version of that primitive (for example, an <code>int</code>
          return type becomes an <CODE>Integer</CODE> type argument, and a
          <code>void</code> return type becomes a <CODE>Void</CODE> type
          argument, which is always <code>null</code>).</DL>
<HR>
<DL>
<DT><PRE>public interface <B>AsyncCallback&lt;T&gt;</B></DL>
</PRE>

<P>
The primary interface a caller must implement to receive a response from a
 remote procedure call.
 
 <p>
 If an RPC is successful, then <A HREF="../../../../../../com/google/gwt/user/client/rpc/AsyncCallback.html#onSuccess(T)"><CODE>onSuccess(Object)</CODE></A> is called, otherwise
 <A HREF="../../../../../../com/google/gwt/user/client/rpc/AsyncCallback.html#onFailure(java.lang.Throwable)"><CODE>onFailure(Throwable)</CODE></A> is called.
 </p>
 
 <p>
 Each callable asynchronous method corresponds to a method in the correlated
 service interface. The asynchronous method always takes an
 <code>AsyncCallback&lt;T&gt;</code> as its last parameter, where
 <code>T</code> is the return type of the correlated synchronous method.
 </p>
 
 <p>
 As an example, suppose the service interface defines a method called
 <code>getShapes</code> as follows:
 
 <pre>
 Shape[] getShapes(String databaseName) throws ShapeException, DbException;
 </pre>
 
 Its asynchronous counterpart method be declared as:
 
 <pre>
 void getShapes(String databaseName, AsyncCallback&lt;Shape[]&gt; callback);
 </pre>
 
 Note that <code>throws</code> declaration is not repeated in the async
 version.
 </p>
 
 <p>
 A call with a typical use of <code>AsyncCallback</code> might look like
 this:
 
 <pre class="code">
 service.getShapes(dbName, new AsyncCallback<Shape[]>() {
   public void onSuccess(Shape[] result) {
     // It's always safe to downcast to the known return type. 
     controller.processShapes(result);
   }
 
   public void onFailure(Throwable caught) {
     // Convenient way to find out which exception was thrown.
     try {
       throw caught;
     } catch (IncompatibleRemoteServiceException e) {
       // this client is not compatible with the server; cleanup and refresh the 
       // browser
     } catch (InvocationException e) {
       // the call didn't complete cleanly
     } catch (ShapeException e) {
       // one of the 'throws' from the original method
     } catch (DbException e) {
       // one of the 'throws' from the original method
     } catch (Throwable e) {
       // last resort -- a very unexpected exception
     }
   }
 });
 </pre>
 
 </p>
<P>

<P>
<HR>

<P>

<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/google/gwt/user/client/rpc/AsyncCallback.html#onFailure(java.lang.Throwable)">onFailure</A></B>(java.lang.Throwable&nbsp;caught)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called when an asynchronous call fails to complete normally.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/google/gwt/user/client/rpc/AsyncCallback.html#onSuccess(T)">onSuccess</A></B>(<A HREF="../../../../../../com/google/gwt/user/client/rpc/AsyncCallback.html" title="type parameter in AsyncCallback">T</A>&nbsp;result)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called when an asynchronous call completes successfully.</TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="onFailure(java.lang.Throwable)"><!-- --></A><H3>
onFailure</H3>
<PRE>
void <B>onFailure</B>(java.lang.Throwable&nbsp;caught)</PRE>
<DL>
<DD>Called when an asynchronous call fails to complete normally.
 <A HREF="../../../../../../com/google/gwt/user/client/rpc/IncompatibleRemoteServiceException.html" title="class in com.google.gwt.user.client.rpc"><CODE>IncompatibleRemoteServiceException</CODE></A>s, <A HREF="../../../../../../com/google/gwt/user/client/rpc/InvocationException.html" title="class in com.google.gwt.user.client.rpc"><CODE>InvocationException</CODE></A>s,
 or checked exceptions thrown by the service method are examples of the type
 of failures that can be passed to this method.
 
 <p>
 If <code>caught</code> is an instance of an
 <A HREF="../../../../../../com/google/gwt/user/client/rpc/IncompatibleRemoteServiceException.html" title="class in com.google.gwt.user.client.rpc"><CODE>IncompatibleRemoteServiceException</CODE></A> the application should try to
 get into a state where a browser refresh can be safely done.
 </p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>caught</CODE> - failure encountered while executing a remote procedure call</DL>
</DD>
</DL>
<HR>

<A NAME="onSuccess(java.lang.Object)"><!-- --></A><A NAME="onSuccess(T)"><!-- --></A><H3>
onSuccess</H3>
<PRE>
void <B>onSuccess</B>(<A HREF="../../../../../../com/google/gwt/user/client/rpc/AsyncCallback.html" title="type parameter in AsyncCallback">T</A>&nbsp;result)</PRE>
<DL>
<DD>Called when an asynchronous call completes successfully.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>result</CODE> - the return value of the remote produced call</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../../com/google/gwt/user/client/rpc/IncompatibleRemoteServiceException.html" title="class in com.google.gwt.user.client.rpc"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../../../index.html?com/google/gwt/user/client/rpc/AsyncCallback.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="AsyncCallback.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>

</BODY>
</HTML>
